<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>视频详情</title>
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_2384888_ojge9md3tr.css
    ">
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="../css/online.css">
    <link rel="stylesheet" href="../css/index.css">
    <script src="../js/vue-v2.6.10.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <script src="https://unpkg.com/vue-router@2.0.0/dist/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <!-- 导航菜单 -->
        <nav>
            <div class="main">
                <img src="../img/public/logo.png" alt="" class="logo">
                <ul>
                    <li><a href="../index.html">首页</a></li>
                    <li class="check"><a href="online.html">全部课程</a></li>
                    <li><a href="javascript:;">在线练习</a></li>
                    <li><a href="javascript:;">精品课程</a></li>
                </ul>
                <div class="search">
                    <div class="left">课程<i class="iconfont icon-down"></i>
                    </div>
                    <input type="text" v-model="search" placeholder="搜索感兴趣的内容">
                    <img src="../img/public/search.png" alt="" @click="getCourseList(1)">
                </div>

                <div class="login" v-if="status">
                    <a href="./loginAndRegister/login.html">登陆</a>
                    /
                    <a href="./loginAndRegister/register.html">注册</a>
                </div>
                <div class="user" v-else="status">
                    <img src="../img/login/user.png" alt="">
                    <div class="userlist">
                        <ul>
                            <li>{{user.name}}</li>
                            <a href="../pages/course.html">
                                <li>课程中心</li>
                            </a>
                            <li>订单中心</li>
                            <li>资金管理</li>
                            <li>个人中心</li>
                            <li class="out">退出登陆</li>
                        </ul>
                    </div>
                </div>

            </div>
        </nav>

        <!-- 主体内容 -->
        <main>
            <div class="row">
                <div class="left">按版本选择</div>
                <div class="right">
                    <ul>
                        <li><a :class="{active:selectType==''}" @click="changeSelect('')">全部</a></li>
                        <li><a :class="{active:selectType=='1'}" @click="changeSelect('1')">java</a></li>
                        <li><a :class="{active:selectType=='2'}" @click="changeSelect('2')">数据库</a></li>
                        <li><a :class="{active:selectType=='3'}" @click="changeSelect('3')">前端</a></li>
                    </ul>
                </div>
            </div>
            <div class="lesson">
                <ul style="text-align:center;">
                    <li v-for="course in courseList">
                        <div class="top">
                            <!-- <a @click="jump(course)"><img
                                :src="'http://192.168.194.223:8080/cs_res/course/pic/'+course.courseImage" alt=""
                                class="m"></a> -->
                            <a :href="'videoDetail.html?'+course.cid"><img
                                    :src="'http://192.168.194.223:8080/cs_res/course/pic/'+course.courseImage" alt=""
                                    class="m"></a>
                            <p>1100人在学习</p>
                        </div>
                        <div class="bottom">
                            <div class="left">
                                <span>{{course.courseName}}</span>
                                <span class="time">RMB{{course.coursePrice}}</span>
                            </div>
                            <div class="right">快速学习</div>
                        </div>
                    </li>
                </ul>
            </div>

            <div class="pageNum">
                <button @click="getCourseList(1)">首页</button>
                <button @click="getCourseList(pre_page)">上一页</button>
                <ul>
                    <li v-for="index in indexs" :class="index==currentPage?'active':''" @click="getCourseList(index)">
                        {{index}}</li>
                </ul>
                <button @click="getCourseList(last_page)">下一页</button>
                <button @click="getCourseList(total_Page)">尾页</button>
            </div>
        </main>
        <footer>
            <div class="cont">
                <div class="main">
                    <p>
                        首页 | 关于我们 | 加入我们 | 合作专区 | 联系我们 | AI开放平台 | 意见反馈 | 漏洞提交 | 隐私政策 | 版权声明 | 反盗链声明 | 网上有害信息举报 | 备案公示 |
                        营业执照
                        | 教师资格证公示
                    </p>
                    <p>
                        京ICP备10218183号-1 京ICP证161188号 七易时代科技有限公司 | 地址：北京市昌平区慧聪采购园 | 电话：010-66666666 | 京公网安备
                        01010102002533号
                    </p>
                    <p>
                        京网文〔2018〕4086-308号 | 网络文化经营许可证：沪网文[2018]4086-308号 | 增值电信业务经营许可证：京B2-20150021 |
                    </p>
                    <p>在线教育许可证：小优课堂经营许可证20188008号 | 互联网教育服务资格证书：(京)-经营性-2018-0011 |</p>
                </div>
            </div>
        </footer>
    </div>
</body>
<script>
    new Vue({
        el: "#app",
        data: {
            status: true,
            search: '',
            selectType: '',
            courseList: '',
            currentPage: 1,
            countRows: 1,
            size: 6,
            user: ''
        },
        methods: {
            changeSelect(index) {
                this.selectType = index;
                this.getCourseList(1);
            },
            getCourseList(currentPage) {
                this.currentPage = currentPage;
                axios({
                    method: "post",
                    url: 'http://192.168.194.223:8080/edu/course',
                    params: {
                        flag: 'show',
                        type: this.selectType,
                        pageSize: this.size,
                        currentPage: currentPage,
                        search: this.search
                    }
                }).then(res => {
                    this.countRows = res.data.countRows;
                    this.courseList = res.data.result;
                });
            },
            jump(course) {
                this.router.push({
                    name: "vedioDetail",
                    params: course
                });
            }
        },
        computed: {
            indexs: function () {
                var left = 1;
                var right = this.total_Page;
                var arr = [];
                while (left <= right) {
                    arr.push(left)
                    left++
                }
                return arr
            },
            total_Page: function () {
                return Math.ceil(this.countRows / this.size);
            },
            pre_page: function () {
                return this.currentPage == 1 ? 1 : this.currentPage - 1;
            },
            last_page: function () {
                return this.currentPage == this.total_Page ? this.total_Page : this.currentPage + 1;
            }
        },
        created() {
            this.getCourseList(1);
            var u = sessionStorage.getItem("user");
            if (u == null || u == '') {
                this.status = true;
            } else {
                this.user = JSON.parse(u);
                this.status = false;
            }
        }
    })
</script>

</html>